<?php

class Photos_model extends CI_Model {
	
	protected $table;

	function __construct(){
		parent::__construct();
		$this->table = 'photos';
	}

	
	
	function insert($title , $path){
		$this->db->insert($this->table, array('title'=>$title, 'path'=>$path));
	}

	function remove_photo($id){
		$path = $this->db->select('path')->get_where($this->table, array('id_photo'=>$id))->result_array();
		unlink($path[0]['path']);
		$this->db->delete($this->table, array('id_photo'=>$id));
	}

	function get_photos(){
		return $this->db->get($this->table)->result_array();
	}

}
?>